<template>
	<view class="nav-bar" :style="{ height: navBarHeight + 'px' }">
		<view class="search" :style="{
        height: menuHeight + 'px',
        'min-height': menuHeight + 'px',
        'line-height': menuHeight + 'px',
        left: menuRight + 'px',
        top: menuTop + 'px',
      }">
			<uni-icons type="back" size="25" @click="back" v-if="backshow"></uni-icons>

			<view class="titlebox">{{ title }}</view>
		</view>

	</view>
</template>

<script>
	export default {
		props: {
			backshow: {
				Boolean,
			},
			title: {
				String,
				default: "",
			},
			navBarHeight: {
				String,
				default: "",
			},
			menuRight: {
				String,
				default: "",
			},
			menuTop: {
				String,
				default: "",
			},
			menuHeight: {
				String,
				default: "",
			},
		},
		data() {
			return {};
		},

		methods: {
			back() {
				const pages = getCurrentPages();
				// 如果当前页面栈的长度为1，说明已经是最顶层页面
				if (pages.length === 1) {
					// 跳转到首页
					uni.reLaunch({
						url: "/pages/home/home", // 替换为你的首页路径
					});
				} else {
					// 返回上一页
					uni.navigateBack({
						delta: 1,
					});
				}
			},
		},
	};
</script>

<style>
	.nav-bar {
		position: fixed;
		width: 100%;
		top: 0;
		color: #fff;
		background: #fff;
		display: flex;
		z-index: 99;
	}

	.nav-bar .search {
		color: black;
		font-size: 14px;
		background: #fff;
		position: absolute;
		width: 730rpx;
		z-index: 99;
		/* padding-left: 14px; */
	}

	.titlebox {
		text-align: center;
		position: absolute;
		top: 0;
		font-size: 32rpx;
		width: 200rpx;
		left: 50%;
		transform: translate(-50%, 0);
		z-index: 99;
	}
</style>